package jparchess.engine;

public class Board {
	
	// the board
	public int[] square = new int[64];
	public boolean whiteCanCastle00;
	public boolean whiteCanCastle000;
	public boolean blackCanCastle00;
	public boolean blackCanCastle000;
	public int enPassantSquare;
	public boolean sideToMove;
	public int material;
	
	// attack boards
	public boolean[] wP_attacks = new boolean[64];
	public boolean[] wN_attacks = new boolean[64];
	public boolean[] wB_attacks = new boolean[64];
	public boolean[] wR_attacks = new boolean[64];
	public boolean[] wQ_attacks = new boolean[64];
	public boolean[] wK_attacks = new boolean[64];
	public boolean[] bP_attacks = new boolean[64];
	public boolean[] bN_attacks = new boolean[64];
	public boolean[] bB_attacks = new boolean[64];
	public boolean[] bR_attacks = new boolean[64];
	public boolean[] bQ_attacks = new boolean[64];
	public boolean[] bK_attacks = new boolean[64];
	
	public void startPosition() {
		// material
		square[D.A1] = D.WHITE_ROOK;
		square[D.B1] = D.WHITE_KNIGHT;
		square[D.C1] = D.WHITE_BISHOP;
		square[D.D1] = D.WHITE_QUEEN;
		square[D.E1] = D.WHITE_KING;
		square[D.F1] = D.WHITE_BISHOP;
		square[D.G1] = D.WHITE_KNIGHT;
		square[D.H1] = D.WHITE_ROOK;
		for (int i = D.A2; i <= D.H2; i++) square[i] = D.WHITE_PAWN;	
		for (int i = D.A3; i <= D.H6; i++) square[i] = D.EMPTY;
		for (int i = D.A7; i <=D.H7 ; i++) square[i] = D.BLACK_PAWN;
		square[D.A8] = D.BLACK_ROOK;
		square[D.B8] = D.BLACK_KNIGHT;
		square[D.C8] = D.BLACK_BISHOP;
		square[D.D8] = D.BLACK_QUEEN;
		square[D.E8] = D.BLACK_KING;
		square[D.F8] = D.BLACK_BISHOP;
		square[D.G8] = D.BLACK_KNIGHT;
		square[D.H8] = D.BLACK_ROOK;
		

		// flags
		whiteCanCastle00 = whiteCanCastle000 = blackCanCastle00 = blackCanCastle000 = true;
		enPassantSquare = -11; // no en-passant position at start-up
		
		sideToMove = D.WHITE_TO_MOVE;
		material = 0;
	}
	
}
